<template>
  <el-form :inline="inline" :model="form" ref="form" :label-width="labelWidth" :label-position='labelPosition'>
    <el-form-item v-for="item in formLabel" :key="item.model" :label="item.label">
      <el-input v-model="form[item.model]" v-if="!item.type"></el-input>
      <el-select v-model="form[item.model]" :placeholder='item.palceholder' v-if="item.type === 'select'">
        <el-option 
             v-for="itm in item.opts" 
             :key="itm.value" 
             :label="itm.label" 
             :value="itm.value">
             </el-option>
      </el-select>
      <el-switch v-model="form[item.model]" v-if="item.type === 'switch'"></el-switch>
      <el-date-picker v-model="form[item.model]" type="date" placeholder="选择日期" v-if="item.type === 'date'" value-format="yyyy-MM-dd"> </el-date-picker>
    </el-form-item>
    <el-form-item><slot></slot></el-form-item>
  </el-form>
</template>
<script>
export default {
  props: {
    inline: Boolean,
    form: Object,
    formLabel: Array,
    labelWidth:{
      default:'60px',
      type:String
    },
    labelPosition:{
       default:'right',
       type:String
    }
  }
}
</script>

<style lang="scss" scoped>
.el-form--inline .el-form-item {
    margin-right: 20px;
}
</style>
